package cn.edu.sjtu.se.role;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPCommand;
import org.apache.commons.net.io.Util;

public class TempClient extends FTPClient {

	public void do_list(PrintStream out) throws IOException {

		Socket socket;

		if ((socket = _openDataConnection_(FTPCommand.LIST, null)) == null) {
			return;
		}

		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
			String line;

			while ((line = reader.readLine()) != null) {
				out.println(line);
			}
		} finally {
			Util.closeQuietly(socket);
		}

		completePendingCommand();
	}

}
